package dictcn.com.model;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;


public class AccessQqUserInfo {
	
	private static final String PREFERENCES_NAME_QQ = "qqUser";

	//设置腾讯微博绑定的账号及其相关默认绑定信息设置
	public static void keepQqUser(Context context, String name) {
		
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_QQ, Context.MODE_PRIVATE);
		Editor editor = pref.edit();
		editor.putString("nick", name);
		editor.putBoolean("bind", false);//同步生词本账号绑定
		editor.putBoolean("sharebind", false);//分享发布消息绑定
		editor.commit();
	}
	
	//同步生词本绑定腾讯账号设置
	public static void keepQqUserBind(Context context, boolean isBind) {
		
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_QQ, Context.MODE_PRIVATE);
		Editor editor = pref.edit();
		editor.putBoolean("bind", isBind);
		editor.commit();
	}
	
	//分享发布信息腾讯账号设置
	public static void keepQqUserShareBind(Context context, boolean isBind) {
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_QQ, Context.MODE_PRIVATE);
		Editor editor = pref.edit();
		editor.putBoolean("sharebind", isBind);
		editor.commit();
	}

	
	//清空腾讯账号所有相关信息
	public static void clearQqUser(Context context){
	    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_QQ, Context.MODE_PRIVATE);
	    Editor editor = pref.edit();
	    editor.clear();
	    editor.commit();
	}

	//读取腾讯账号用户名
	public static String readQqUser(Context context){
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_QQ, Context.MODE_PRIVATE);	
		return pref.getString("nick", "-1");
	}
	
	//读取腾讯账号是否同步生词本绑定
	public static boolean readQqUserBind(Context context){
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_QQ, Context.MODE_PRIVATE);	
		return pref.getBoolean("bind",false);
	}
	
	//读取腾讯账号是否发布分享绑定
	public static boolean readQqUserShareBind(Context context){
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_QQ, Context.MODE_PRIVATE);
		return pref.getBoolean("sharebind",false);
	}
}
